home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C15 / Pvdef.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  738 b   |  37 lines

  1. //: C15:Pvdef.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Pure virtual base definition
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. class Base {
  11. public:
  12.   virtual void v() const = 0;
  13.   virtual void f() const = 0;
  14.   // Inline pure virtual definitions illegal:
  15.   //!  virtual void g() const = 0 {}
  16. };
  17.  
  18. // OK, not defined inline
  19. void Base::f() const {
  20.   cout << "Base::f()\n";
  21. }
  22.  
  23. void Base::v() const { cout << "Base::v()\n";}
  24.  
  25. class D : public Base {
  26. public:
  27.   // Use the common Base code:
  28.   void v() const { Base::v(); }
  29.   void f() const { Base::f(); }
  30. };
  31.  
  32. int main() {
  33.   D d;
  34.   d.v();
  35.   d.f();
  36. } ///:~
  37.